# Copyright (c) 2024 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# The validator library is designed to provide a backend-agnostic method
# to query the status of entities used in tests.

package(
    default_visibility = ["//visibility:public"],
    licenses = ["notice"],
)

cc_library(
    name = "validator",
    srcs = ["validator.cc"],
    hdrs = ["validator.h"],
    deps = [
        ":validator_backend",
        "@com_google_absl//absl/algorithm:container",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "validator_backend",
    srcs = ["validator_backend.cc"],
    hdrs = ["validator_backend.h"],
    deps = [
        "@com_github_google_glog//:glog",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/meta:type_traits",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
)

cc_library(
    name = "common_backend",
    testonly = 1,
    srcs = ["common_backend.cc"],
    hdrs = ["common_backend.h"],
    deps = [
        ":validator",
        ":validator_backend",
        ":validator_lib",
        "//thinkit:ssh_client",
        "@com_google_absl//absl/functional:bind_front",
    ],
)

cc_test(
    name = "validator_backend_test",
    srcs = ["validator_backend_test.cc"],
    deps = [
        ":validator_backend",
        "//gutil/gutil:status_matchers",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest_main",
    ],
)

cc_library(
    name = "pins_backend",
    testonly = 1,
    srcs = ["pins_backend.cc"],
    hdrs = ["pins_backend.h"],
    deps = [
        ":validator",
        ":validator_backend",
        ":validator_lib",
        "//thinkit:switch",
        "@com_google_absl//absl/container:flat_hash_map",
        "@com_google_absl//absl/container:flat_hash_set",
        "@com_google_absl//absl/functional:bind_front",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
    ],
)

cc_library(
    name = "validator_lib",
    testonly = 1,
    srcs = ["validator_lib.cc"],
    hdrs = ["validator_lib.h"],
    deps = [
        "//gutil/gutil:status",
        "//lib/gnmi:gnmi_helper",
        "//lib/gnoi:gnoi_helper",
        "//thinkit:ssh_client",
        "//thinkit:switch",
        "@com_github_gnmi//proto/gnmi:gnmi_cc_grpc_proto",
        "@com_github_gnoi//system:system_cc_grpc_proto",
        "@com_github_gnoi//system:system_cc_proto",
        "@com_github_google_glog//:glog",
        "@com_github_grpc_grpc//:grpc++",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_grpc",
        "@com_github_p4lang_p4runtime//:p4runtime_cc_proto",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_absl//absl/types:span",
    ],
)

cc_test(
    name = "validator_lib_test",
    srcs = ["validator_lib_test.cc"],
    deps = [
        ":validator_lib",
        "//gutil/gutil:status_matchers",
        "//thinkit:switch",
        "@com_google_absl//absl/status",
        "@com_google_absl//absl/status:statusor",
        "@com_google_absl//absl/strings",
        "@com_google_absl//absl/time",
        "@com_google_googletest//:gtest_main",
    ],
)
